﻿using System;
using System.Runtime.Serialization;
using System.Web;

namespace Virgee.Common.Services.Exceptions
{
    [Serializable]
    public class HttpRequestFailedException : HttpException, ISerializable
    {
        #region Properties
        private string ResponseContent { get; set; }
        #endregion // Properties

        #region Constructors
        private HttpRequestFailedException()
        {
            // This space intentionally left blank 
        }

        public HttpRequestFailedException(string responseContent)
            : base()
        {
            ResponseContent = responseContent;
        }

        public HttpRequestFailedException(string message, string responseContent)
            : base(message)
        {
            ResponseContent = responseContent;
        }

        public HttpRequestFailedException(int httpCode, string message, string responseContent)
            : base(httpCode, message)
        {
            ResponseContent = responseContent;
        }

        public HttpRequestFailedException(string message, string responseContent, Exception innerException)
            : base(message, innerException)
        {
            ResponseContent = responseContent;
        }

        public HttpRequestFailedException(string message, string responseContent, int hr)
            : base(message, hr)
        {
            ResponseContent = responseContent;
        }

        public HttpRequestFailedException(int httpCode, string message, string responseContent, Exception innerException)
            : base(httpCode, message, innerException)
        {
            ResponseContent = responseContent;
        }

        public HttpRequestFailedException(int httpCode, string message, string responseContent, int hr)
            : base(httpCode, message, hr)
        {
            ResponseContent = responseContent;
        }

        public HttpRequestFailedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
            : base(info, context)
        {
            Is.NotNull(info, "info");

            ResponseContent = (string)info.GetValue("ResponseContent", typeof(string));
        }

        #endregion // Constructors

        #region ISerializable Implementation
        public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            Is.NotNull(info, "info");

            info.AddValue("ResponseContent", ResponseContent);
        }
        #endregion // ISerializable Implementation
    }
}
